package com.fr.privilege.providers;

import com.fr.base.StringUtils;
import com.fr.base.core.json.JSONException;
import com.fr.base.core.json.JSONObject;
import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLableReader;
import com.fr.privilege.authority.Authority;
import com.fr.privilege.ui.CustomLogioutUI;
import com.fr.privilege.ui.DefaultLoginoutUI;
import com.fr.privilege.ui.LoginoutUI;
import com.fr.report.io.xml.ReportXMLUtils;

public abstract class AbstractAuthenticationProvider
  implements AuthenticationProvider
{
  private static final long serialVersionUID = 8764588648703810380L;
  private LoginoutUI loginoutUI;

  public LoginoutUI getLoginoutUI()
  {
    return this.loginoutUI;
  }

  public void setLoginoutUI(LoginoutUI paramLoginoutUI)
  {
    this.loginoutUI = paramLoginoutUI;
  }

  public Authority[] listAuthorities()
    throws Exception
  {
    return new Authority[0];
  }

  public void readJSON(JSONObject paramJSONObject)
    throws JSONException
  {
    if (StringUtils.isNotBlank(paramJSONObject.getString("loginpath")))
      this.loginoutUI = new CustomLogioutUI();
    else
      this.loginoutUI = new DefaultLoginoutUI();
    this.loginoutUI.readJSON(paramJSONObject);
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    if (paramXMLableReader.isChildNode())
    {
      String str = paramXMLableReader.getTagName();
      if ("LoginoutUI".equals(str))
        this.loginoutUI = ((LoginoutUI)ReportXMLUtils.readXMLable(paramXMLableReader));
    }
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    if (this.loginoutUI != null)
      ReportXMLUtils.writeXMLable(paramXMLPrintWriter, this.loginoutUI, "LoginoutUI");
  }

  public Object clone()
    throws CloneNotSupportedException
  {
    AbstractAuthenticationProvider localAbstractAuthenticationProvider = (AbstractAuthenticationProvider)super.clone();
    return localAbstractAuthenticationProvider;
  }
}